<!--
db面板类型 针对bill_model数据的组件
tab+chart用来展示多维度的列表
-->
<script>
import $ from "@/common";
import Time from "@/common/time";
import panelTabChart from "./panelTabChart";
export default {
  extends: panelTabChart,
  data() {
    return {
      fields: {
        start_time: "period_start",
        end_time: "period_end"
      }
    };
  },
  computed: {
    postData() {
      var date = this.dateRange;
      return {
        ...(this.model.post_data || {}),
        [this.fields.start_time]: date[0],
        [this.fields.end_time]: date[1],
        ...this.param
      };
    }
  },
  methods: {
    getData() {
      this.loading = true;
      var data = this.postData;
      if (
        typeof data[this.fields.start_time] === "number" ||
        data[this.fields.start_time].constructor === Date
      ) {
        data[this.fields.start_time] = Time.toDate(
          data[this.fields.start_time]
        );
      }
      if (
        typeof data[this.fields.end_time] === "number" ||
        data[this.fields.end_time].constructor === Date
      ) {
        data[this.fields.end_time] = Time.toDate(data[this.fields.end_time]);
      }
      //data[this.fields.end_time] = Time.toTs(data[this.fields.end_time]);
      //data[this.fields.start_time] = Time.toTs(data[this.fields.start_time]);
      return $.link(this.fetchPath, data)
        .then(res => {
          this.$set(this, "data", res.data.data);
          if (res.data.totalPageCount > 1 && res.data.data.length >= res.data.pageSize) {
            this.dataOverflow = true;
          } else {
            this.dataOverflow = false;
          }
        })
        .finally(() => {
          this.loading = false;
        });
    }
  }
};
</script>
